﻿<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Logs.aspx.cs" Inherits="YetiManagement.Logs" %>


<asp:Content ID="headContent" ContentPlaceHolderID="head" runat="server"></asp:Content>
   
    
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <script runat="server">

 private void OnDSUpdatedHandler(Object source, SqlDataSourceStatusEventArgs e)
 {
     labelka.Text = e.AffectedRows > 0 ? "Update successful!" : "No data updated!";
 }

    </script>
    
     <div class = "divLabel">
       List of all sessions<br />
    </div>
    <asp:GridView ID="SessionsGridView"  runat="server" AutoGenerateColumns="False" CssClass="DDGridView" 
        RowStyle-CssClass="td" HeaderStyle-CssClass="th"
        DataKeyNames="ID_session" DataSourceID="SessionsSource" 
        onselectedindexchanged="SessionsGridView_SelectedIndexChanged" 
        AllowSorting="True" onrowdatabound="SessionsGridView_RowDataBound" 
        >
        <Columns>
            <asp:TemplateField ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                        CommandName="Select" Text="Select"></asp:LinkButton>
                   
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="ID_session" HeaderText="ID_session" ReadOnly="True" 
                SortExpression="ID_session" />
            <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
            <asp:BoundField DataField="User_IP" HeaderText="User_IP" 
                SortExpression="User_IP" />
            <asp:BoundField DataField="User_name" HeaderText="User_name" 
                SortExpression="User_name" />
            <asp:BoundField DataField="End_date" HeaderText="End_date" 
                SortExpression="End_date" />
            <asp:BoundField DataField="Start_date" HeaderText="Start_date" 
                SortExpression="Start_date" />
            <asp:BoundField DataField="Reason" HeaderText="Reason" 
                SortExpression="Reason" />
        </Columns>
        
<HeaderStyle CssClass="th"></HeaderStyle>

<RowStyle CssClass="td"></RowStyle>
        
    </asp:GridView>

    <asp:SqlDataSource ID="SessionsSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:yetiConnectionString %>" 
        SelectCommand="SELECT [ID_session], [State], [User_IP], [User_name], [End_date], [Start_date], [Reason] FROM [Session]">
    </asp:SqlDataSource>

    <br />
     <div class = "divLabel">
       Details of selected conversation<br />
    </div>

    
    <asp:Label ID="labelka" runat="server" ></asp:Label>

    <br />
    <asp:GridView ID="GridViewTurns" runat="server" CssClass="DDGridView" 
        RowStyle-CssClass="td" HeaderStyle-CssClass="th" 
        AllowSorting="True" DataSourceID="TurnsSource" 
        AutoGenerateEditButton="True"   
         AutoGenerateColumns="False" OnRowEditing="GridViewTurns_RowEditing">
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
             <asp:BoundField DataField="ID_turn" HeaderText="ID_turn" ReadOnly="False" 
                SortExpression="ID_turn" />
            <asp:BoundField DataField="ID_pattern" HeaderText="ID_pattern" SortExpression="ID_pattern" />        
            <asp:BoundField DataField="PatternContent" HeaderText="PatternContent" SortExpression="PatternContent" />
            <asp:BoundField DataField="ID_response" HeaderText="ID_response" SortExpression="ID_response" />                   
            <asp:BoundField DataField="ResponseContent" HeaderText="ResponseContent" 
                SortExpression="ResponseContent"  />
        </Columns>
<HeaderStyle CssClass="th"></HeaderStyle>

<RowStyle CssClass="td"></RowStyle>
    </asp:GridView>

    <asp:SqlDataSource ID="TurnsSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:yetiConnectionString %>"
        SelectCommand="SELECT t.ID_turn,p.[ID_pattern], p.[Content] AS PatternContent,r.[ID_response], r.[Content] AS ResponseContent FROM Pattern AS p INNER JOIN Turn AS t ON p.ID_pattern = t.ID_pattern INNER JOIN Response AS r ON t.ID_response = r.ID_response AND p.ID_pattern = r.ID_pattern INNER JOIN Session AS s ON t.ID_session = s.ID_session "
        UpdateCommand="UPDATE Pattern SET Content = @PatternContent WHERE ID_pattern = @ID_pattern  UPDATE Response SET Content = @ResponseContent WHERE ID_response = @ID_response" OnUpdated="OnDSUpdatedHandler"
 >
       
    </asp:SqlDataSource>

</asp:Content>

    

